import {defineStore} from 'pinia'
import {computed, ref} from 'vue'

export const useTabBarStore = defineStore('tabBar', () => {
    const roleType = ref(1) // 0 求职者  1 招聘方

    /* 根据 roleType 动态生成 */
    const list = computed(() => [
        {
            name: '首页',
            icon: '/static/icon/tabbar/home.png',
            activeIcon: '/static/icon/tabbar/home-at.png',
            url: '/pages/index/index'
        },
        {
            name: '沟通',
            icon: '/static/icon/tabbar/message.png',
            activeIcon: '/static/icon/tabbar/message-at.png',
            url: '/pages/index/message'
        },
        {
            name: roleType.value ? '找工作' : '招人才', // 这里会随 roleType 变化
            icon: '/static/icon/tabbar/work.png',
            activeIcon: '/static/icon/tabbar/work-at.png',
            url: '/pages/index/work'
        },
        {
            name: '面试邀请',
            icon: '/static/icon/tabbar/invite.png',
            activeIcon: '/static/icon/tabbar/invite-at.png',
            url: '/pages/index/invite'
        },
        {
            name: '我的',
            icon: '/static/icon/tabbar/user.png',
            activeIcon: '/static/icon/tabbar/user-at.png',
            url: '/pages/index/user'
        }
    ])

    const currentIndex = ref(0)

    function setCurrent(idx) {
        currentIndex.value = idx
    }

    return {list, currentIndex, roleType, setCurrent}
})